<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增专家评分')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-scoring-add" >

<!--            <input name="expertId" th:field="*{itemName}" type="text">-->


            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table">

                </table>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var addFlag = [[${@permission.hasPermi('system:items:edit')}]];
        var firstLevelCategoryDatas = [[${@dict.getType('sys_pf_first')}]];
        var scoringMethodDatas = [[${@dict.getType('sys_pf_dafenxs')}]];
        var isObjectiveDatas = [[${@dict.getType('sys_pf_iskg')}]];

        var prefix = ctx + "system/scoring"
        var prefix1 = ctx + "system/items";
        $("#form-scoring-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            var data = $("#" + table.options.id).bootstrapTable('getData');
            console.log(JSON.stringify(data));
            if ($.validate.form()) {
                //$.operate.save(prefix + "/add", $('#form-scoring-add').serialize());
                $.operate.save(prefix + "/add", $('#'+table.options.id).bootstrapTable('getData'));
            }
        }

        $(function() {
            console.log()
            var options = {
                url: prefix1 + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "评分项配置",
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'itemId',
                        title: '评分项ID',
                        visible: false
                    },
                    {
                        field: 'firstLevelCategory',
                        title: '一级分类',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(firstLevelCategoryDatas, value);
                        }
                    },
                    {
                        field: 'secondLevelCategory',
                        title: '二级分类'
                    },
                    {
                        field: 'itemName',
                        title: '评分项名称'
                    },
                    {
                        field: 'scoringMethod',
                        title: '打分形式',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(scoringMethodDatas, value);
                        }
                    },
                    {
                        field: 'scoreConfig',
                        title: '分值配置',
                    },
                    {
                        field: 'weight',
                        title: '权重'
                    },
                    {
                        field: 'isObjective',
                        title: '是否客观分',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(isObjectiveDatas, value);
                        }
                    },
                    {
                        field: 'itemBz',
                        title: '指标评分标准'
                    },
                    {
                        title: '操作',
                        field: 'scoreSet',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var actions = [];
                            if(row.scoringMethod == '2'){
                                actions.push('<input type="text" width="10px" name="scoreSet" />');
                            }
                            //actions.push('<a class="btn btn-success btn-xs ' + addFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.itemId + '\')"><i class="fa fa-edit"></i>打分</a> ');
                            if(row.scoringMethod == '1'){
                                actions.push('<select name="scoreSet">\n' +
                                    ' <option value="1">是</option>\n' +
                                    ' <option value="2">否</option>\n' +
                                    ' </select>');
                            }
                            if(row.scoringMethod == '3'){
                                actions.push('<select name="scoreSet">\n' +
                                    ' <option value="1">A</option>\n' +
                                    ' <option value="2">B</option>\n' +
                                    ' <option value="3">C</option>\n' +
                                    ' <option value="4">D</option>\n' +
                                    ' </select>');
                            }
                            return actions.join('');
                        }
                    }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>